package com.wushi.lenovo.asia5b.app_ui.orderdetail;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.mvp.base.BaseAppCompatActivity;
import com.mvp.base.BaseFragmentPagerAdapter;
import com.mvp.base.BaseSimpleFragment;
import com.wushi.lenovo.asia5b.R;
import com.wushi.lenovo.asia5b.app_model.good.orderitem.OrderItemType;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import timber.log.Timber;

/**
 * Created by zhangyuncai on 2020/3/12.
 */
public class OrderDetailActivity extends BaseAppCompatActivity {

    @BindView(R.id.vp_orderdetail)
    ViewPager viewPager;

    public int order_id;
    public OrderItemType orderItemType = null;

    public static void startOrderDetailActivity(Context context, int id, OrderItemType orderItemType) {
        Intent intent = new Intent(context, OrderDetailActivity.class);
        intent.putExtra("id", id);
        intent.putExtra("type", orderItemType);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_orderdetail2;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        order_id = getIntent().getIntExtra("id", 0);
        orderItemType = (OrderItemType) getIntent().getSerializableExtra("type");
        Timber.d("--->>>>>>>>---订单详细:" + orderItemType.name());

        List<Fragment> fragments = new ArrayList<>();
        if (orderItemType == OrderItemType.Verification) {
            fragments.add(BaseSimpleFragment.sNewStance(mActivity, OrderDetailVeriFragment.class));
        } else if (orderItemType == OrderItemType.Payment) {
            fragments.add(BaseSimpleFragment.sNewStance(mActivity, OrderDetailPaymentFragment.class));
        } else if (orderItemType == OrderItemType.Delivery || orderItemType == OrderItemType.History) {
            fragments.add(BaseSimpleFragment.sNewStance(mActivity, OrderDetailDeliveryFragment.class));
        } else if (orderItemType == OrderItemType.Problematic) {
            fragments.add(BaseSimpleFragment.sNewStance(mActivity, OrderDetailProblemFragment.class));
        }
        viewPager.setAdapter(new BaseFragmentPagerAdapter(getSupportFragmentManager(), fragments));
    }
}
